import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const store = new Vuex.Store({
	state: {
		checkList: [],
		unReadNum: 0,
		deviceData: {},
		isOpenTimer: true,
		blueCurrentToConnectDevice: {}, //当前需要连接的车辆，主要用于车辆绑定时使用，因为验证车辆的时候，车辆还没有绑定
		isToIndex: false, //因为跳转首页会触发蓝牙程序，用此字段判断是点击了返回首页，还是用户自行返回的首页
		blueConnectTimer: null,
		lastBike: {},
		catchCodeList: [], //异常列表
		maintainForm: {}, //主要用于编辑保养
		verifyUrl: "",
		bluetoothDevice: {},
		isExecOnload:false,//是否程序执行了onload事件 
		respondPackage:'',
		isConnected: false,
		weather: '',
		specialAppOnShow:false,//特殊情况触发APPOnShow  1、跳转到导航，2、去认证、3、选择图片文件 
		initxWidth: 0,
		bluetoothContent: "", //蓝牙处于什么状态的提示，比如说在连接中
		mapDataPoint:{},
		indexDataPoint:{},
		detailDataPoint:{},
		odometerDataPoint:{},
		guardDataPoint:{},
		drivingDataPoint:{},
		currentBike:{},
		enduranceMileage:{}, //续航里程
		mapMode:'map' ,//地图页面的模式 map、fense、location
		targetCarStatus:{},
		shakeValue:{},
		isProduct:false
	},
	mutations: {
		setTargetCarStatus(state, targetCarStatus) {
			state.targetCarStatus = targetCarStatus;
			uni.setStorageSync("targetCarStatus", targetCarStatus); 
		},
		setIsProduct(state, isProduct) {
			state.isProduct = isProduct;
		},
		setMapMode(state, mapMode) {
			state.mapMode = mapMode
		},
		setEnduranceMileage(state, enduranceMileage) {
			state.enduranceMileage = enduranceMileage
		},
		setCheckList(state, checkList) {
			state.checkList = checkList
		},
		setIsToIndex(state, isToIndex) {
			state.isToIndex = isToIndex
		},
		setUnReadNum(state, unReadNum) {
			state.unReadNum = unReadNum
		},
		setDeviceData(state, deviceData) {
			state.deviceData = deviceData
		},
		setBlueCurrentToConnectDevice(state, blueCurrentToConnectDevice) {
			state.blueCurrentToConnectDevice = blueCurrentToConnectDevice
		},
		setIsOpenTimer(state, isOpenTimer) {
			state.isOpenTimer = isOpenTimer
		},
		setBlueConnectTimer(state, blueConnectTimer) {
			state.blueConnectTimer = blueConnectTimer
		},
		setLastBike(state, lastBike) {
			state.lastBike = lastBike
		},
		setCatchCodeList(state, catchCodeList) {
			state.catchCodeList = catchCodeList
		},
		setMaintainForm(state, maintainForm) {
			state.maintainForm = maintainForm
		},
		setVerifyUrl(state, verifyUrl) {
			state.verifyUrl = verifyUrl
		},
		setBluetoothDevice(state, bluetoothDevice) {
			state.bluetoothDevice = bluetoothDevice
		},
		setIsExecOnload(state, isExecOnload) {
			state.isExecOnload = isExecOnload
		},
		setRespondPackage(state, respondPackage) {
			state.respondPackage = respondPackage
		},
		setIsConnected(state, isConnected) {
			state.isConnected = isConnected
		},
		setWeather(state, weather) {
			state.weather = weather
		},
		setSpecialAppOnShow(state, specialAppOnShow) {
			state.specialAppOnShow = specialAppOnShow
		},
		setInitxWidth(state, initxWidth) {
			state.initxWidth = initxWidth
		},
		setBluetoothContent(state, bluetoothContent) {
			state.bluetoothContent = bluetoothContent
		},
		
		setMapDataPoint(state, mapDataPoint) {
			state.mapDataPoint = mapDataPoint
		},
		setIndexDataPoint(state, indexDataPoint) {
			state.indexDataPoint = indexDataPoint
		},
		setDetailDataPoint(state, detailDataPoint) {
			state.detailDataPoint = detailDataPoint
		},
		setOdometerDataPoint(state, odometerDataPoint) {
			state.odometerDataPoint = odometerDataPoint
		},
		setGuardDataPoint(state, guardDataPoint) {
			state.guardDataPoint = guardDataPoint
		},
		setDrivingDataPoint(state, drivingDataPoint) {
			state.drivingDataPoint = drivingDataPoint
		},
		setCurrentBike(state, currentBike){
			state.currentBike = currentBike;
			uni.setStorageSync("currentBike", currentBike); 
		},
		setLoginUser(state, loginUser){
			state.loginUser = loginUser;
			uni.setStorageSync("loginUser", loginUser); 
		},
		setShakeValue(state, shakeValue){
			state.shakeValue = shakeValue;
			uni.setStorageSync("shakeValue", shakeValue); 
		},
	},
	actions: {
		// increment({
		// 	commit
		// }) {
		// 	commit('increment')
		// }
	}
})
export default store
